package cn.edu.buu.hospital.entity;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;
/**
 * 支付记录实体类
 */
public class Pay implements Serializable {
    // 支付ID（主键）
    private Long payid;
    // 预约ID（外键）
    private Long appointmentid;
    // 支付金额
    private BigDecimal amount;
    // 支付状态：0-未支付，1-已支付
    private Integer paystatus;
    // 支付方式：微信、支付宝、现金
    private String payway;
    // 支付时间
    private LocalDateTime createtime;
    // 订单号
    private String orderNo;
    // 支付时间字符串（兼容字段）
    private String payTime;
    // 添加关联的Appointment对象
    private Appointment appointment;
    // 无参构造方法
    public Pay() {
    }
    // 全参构造方法
    public Pay(Long payid, Long appointmentid, BigDecimal amount, Integer paystatus, String payway, LocalDateTime createtime) {
        this.payid = payid;
        this.appointmentid = appointmentid;
        this.amount = amount;
        this.paystatus = paystatus;
        this.payway = payway;
        this.createtime = createtime;
    }
    // getter和setter方法
    public Long getPayid() {
        return payid;
    }

    public void setPayid(Long payid) {
        this.payid = payid;
    }

    public Long getAppointmentid() {
        return appointmentid;
    }

    public void setAppointmentid(Long appointmentid) {
        this.appointmentid = appointmentid;
    }
    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    public Integer getPaystatus() {
        return paystatus;
    }

    public void setPaystatus(Integer paystatus) {
        this.paystatus = paystatus;
    }

    public String getPayway() {
        return payway;
    }

    public void setCreatetime(LocalDateTime createtime) {
        this.createtime = createtime;
    }
    
    public Appointment getAppointment() {
        return appointment;
    }

    public void setAppointment(Appointment appointment) {
        this.appointment = appointment;
    }
    
    public void setAppointmentId(Long appointmentId) {
        this.appointmentid = appointmentId;
    }
    
    public Long getAppointmentId() {
        return this.appointmentid;
    }
    
    public void setPayMethod(String payMethod) {
        this.payway = payMethod;
    }
    
    public void setPayStatus(Integer payStatus) {
        this.paystatus = payStatus;
    }
    
    public void setPayTime(String payTime) {
        this.payTime = payTime;
    }
    
    public String getPayTime() {
        return payTime;
    }
    
    public void setOrderNo(String orderNo) {
        this.orderNo = orderNo;
    }
    
    // 为了兼容JSP页面中的属性名
    public Long getPayId() {
        return getPayid();
    }
    
    public Integer getStatus() {
        return getPaystatus();
    }
    
    public String getPayMethod() {
        return getPayway();
    }

    public String getOrderNo() {
        // 直接使用自增的payid作为订单号，格式为PAY+payid
        // 注意：payid在插入数据库后才会有值，所以在页面显示时才能正确获取
        return payid != null ? "PAY" + payid : "PAY" + System.currentTimeMillis();
    }
    // toString方法
    @Override
    public String toString() {
        return "Pay{" +
                "payid=" + payid +
                ", appointmentid=" + appointmentid +
                ", amount=" + amount +
                ", paystatus=" + paystatus +
                ", payway='" + payway + '\'' +
                ", createtime=" + createtime +
                ", appointment=" + appointment +
                '}';
    }
}